package com.ice.crm.commons;

import java.util.List;

// 封装分页的方法
public class Page<T> {
    // 当前页码  通常页面传递
    private Integer pageNum;
    // 每页显示多少条数据  通常页面传递或后台固定
    private Integer pageSize;
    // 数据的总条数  数据库统计得到
    private Integer total;
    // 总页数 pageCount = total / pageSize   如果有余数则  pageCount++   根据上面的数据计算得到的
    private Integer pageCount;
    // 跳过的记录数量  skipNum = (pageNum -1)*pageSize   根据上面的数据计算得到的
    private Integer skipNum;
    // 具体返回的数据
    private List<T> dataList;


    public Page(Integer pageNum, Integer pageSize, Integer total) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        this.pageCount = total / pageSize;
        if (total % pageSize > 0) {
            this.pageCount++;
        }
        this.skipNum = (pageNum - 1) * pageSize;
    }

    public Page() {
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
    }

    public Integer getSkipNum() {
        return skipNum;
    }

    public void setSkipNum(Integer skipNum) {
        this.skipNum = skipNum;
    }

    public List getDataList() {
        return dataList;
    }

    public void setDataList(List dataList) {
        this.dataList = dataList;
    }
}
